package com.example.studentdemo.mapper;

import com.example.studentdemo.entity.Subject;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SubjectMapper {
    List<Subject> selectAll(Subject subject);

    void insert(Subject subject);

    @Select("select * from `subject` where name = #{name}")
    Subject selectByName(String name);

    void updateById(Subject subject);

    @Delete("delete from `subject` where id = #{id}")
    void deleteById(Integer id);

    @Select("select * from `subject` where id = #{id}")
    Subject selectById(Integer id);

    @Select("select s.* from `subject` s join subject_student ss on s.id = ss.subject_id where ss.student_id = #{studentId}")
    List<Subject> selectByStudentId(Integer studentId);
}